<?php

require_once 'BaseHelper.class.php';

class CustomerHelper extends BaseHelper {
	
	public static $MODULE_NAME = "Customer"; //数据库操作的模块名

	//------------------------------------基本函数开始----------------------------------------
	public static function add($data,$displaySQL = false) {
		return parent::add ( self::$MODULE_NAME, $data,$displaySQL );
	}
	public static function update($data, $whereStr="",$displaySQL = false) {
		return parent::update ( self::$MODULE_NAME, $data, $whereStr,$displaySQL );
	}
	public static function updateSQL($sql,$displaySQL = false) {
		return parent::updateSQL( self::$MODULE_NAME, $sql,$displaySQL);
	}
	public static function delete($whereStr="",$displaySQL = false) {
		return parent::delete ( self::$MODULE_NAME, $whereStr ,$displaySQL);
	}
	public static function getObject($whereStr="",$displaySQL = false) {
		return parent::getObject ( self::$MODULE_NAME, $whereStr ,$displaySQL);
	}
	public static function queryObject($sql,$displaySQL = false) {
		return parent::queryObject ( self::$MODULE_NAME, $sql ,$displaySQL);
	}
	public static function queryForInt($sql,$displaySQL = false) {
		return parent::queryForInt ( self::$MODULE_NAME, $sql ,$displaySQL);
	}
	public static function getList($whereStr = '', $orderStr = '', $limitNum = 0,$displaySQL = false) {
		return parent::getList ( self::$MODULE_NAME, $whereStr, $orderStr, $limitNum ,$displaySQL);
	}
	public static function queryList($sql = '', $displaySQL = false) {
		return parent::queryList(self::$MODULE_NAME,$sql,$displaySQL);
	}
	//------------------------------------基本函数结束----------------------------------------


	//------------------------------------自定义函数开始--------------------------------------
	//将获取到的客服列表进行分类
	public static function uniqueList($arr) {
		$list = array();
		$qq_customer_index = 0;
		$ww_customer_index = 0;
		$tel_customer_index = 0;
		foreach ($arr as $obj){
			if($obj["customer_type"] == "QQ帐号"){
				$list["qq_customer_list"][$qq_customer_index] = $obj;
				$qq_customer_index++;
			}
			if($obj["customer_type"] == "旺旺帐号"){
				$list["ww_customer_list"][$ww_customer_index] = $obj;
				$ww_customer_index++;
			}
			if($obj["customer_type"] == "电话热线"){
				$list["tel_customer_list"][$tel_customer_index] = $obj;
				$tel_customer_index++;
			}
		}
		foreach ($list["qq_customer_list"] as $key=>&$vo){
			$vo["first"] = $key == 0?true:false;
			$vo["last"] = $key == (count($list["qq_customer_list"])-1)?true:false;
		}
		foreach ($list["ww_customer_list"] as $key=>&$vo){
			$vo["first"] = $key == 0?true:false;
			$vo["last"] = $key == (count($list["ww_customer_list"])-1)?true:false;
		}
		foreach ($list["tel_customer_list"] as $key=>&$vo){
			$vo["first"] = $key == 0?true:false;
			$vo["last"] = $key == (count($list["tel_customer_list"])-1)?true:false;
		}
		return $list;
	}
	
	//------------------------------------自定义函数结束--------------------------------------


}